<template>
	<view>
		<uni-nav-bar 
		statusBar="true" 
		:fixed="true" 
		:border="false"
		backgroundColor="#1D7DFF"
		color="#ffffff">
			<view class="index-top-nav-title" slot="middle">
				<view class="index-top-nav-l">
					<i class="icon iconfont icon-arrow-left" @tap.stop="back"></i>
					<view class="index-top-nav-title-t">{{i18n.RegularInvestment}}</view>
				</view>
				<view class="index-top-nav-r" @tap.stop="jumpList">
					<view class="index-top-nav-title-t">{{i18n.bili}}</view>
				</view>
				<!-- <text @tap.stop="jumpList" class="iconfonts">{{i18n.bili}}</text> -->
			</view>
		</uni-nav-bar>
		<view class="fund-live-title">
			<view class="fund-live-title-bottom">
				<view class="fund-live-title-bottom-item">
					<text>{{i18n.yesterday_income}}(BTC)</text>
					<view>0</view>
				</view>
				<view class="fund-live-title-bottom-item">
					<text>{{i18n.total_income}}(BTC)</text>
					<view>0</view>
				</view>
			</view>
		</view>

		<view class="fund-regular-content">
			<view class="fund-regular-content-title">{{i18n.Package_name}}</view>
			
			<block v-for="(item,index) in list" :key="index">
				<view class="fund-ragular-content-item" @tap.stop="jumpDetail(item)">
					<view class="fund-ragular-content-item-title">
						<view class="fund-ragular-content-item-title-i">
							<view>{{item.title}}</view>
							<text>{{item.coin}}</text>
						</view>
						<text>{{i18n.Closed_period}} {{item.day}}{{i18n.day}}</text>
					</view>
					<view class="fund-ragular-content-item-content">
						<view class="fund-ragular-content-item-title-l">
							<view>{{item.sl}}</view>
							<text>{{i18n.day_rate}}</text>
						</view>
						<view class="fund-ragular-content-item-title-c">
							<view>{{i18n.Raised}}：{{item.buy_num}}/{{item.max}}{{item.coin}}</view>
						</view>
						<view class="fund-ragular-content-item-title-r">
							<view>{{i18n.Calculating}}</view>
							<text @tap.stop="toDetail(item)">{{i18n.see_details}}</text>
						</view>
					</view>
				</view>
			</block>
			
		</view>
		
		<load v-if="showLoad"></load>
	</view>
</template>

<script>
	import Toast from '@/components/toast/toast.vue';
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
	import Load from '../../components/common/load.vue';
	import {fetch, _updataTabBar, showToast, pageto, forceUpdate} from '@/common/js/util.js';
	import {mapGetters, mapMutations} from 'vuex' 
	export default {
		data() {
			return {
				showLoad:false,
				list:[],
				news:[],
				daysum:0,
				totalsum:0
			}
		},
		onShow() {
			this.getsList();
			this.empty();
			this.getSHopList();
		},
		computed:{
			i18n() {
				return this.$t('message');
			},
			...mapGetters([
				'getRequestUrl',
				"getLoginInfo",
				'getTextArr',
				'getLangType',
				'getLang'
			])
		},
		onNavigationBarButtonTap(e) {
			console.log(e);
			if(e.index==0){
				this.jumpList()
			}
		},
		components:{
			Toast,uniNavBar,Load
		},
		methods:{
			...mapMutations(['setPackages']),
			getsList(){
				let url = this.getRequestUrl + '/api/User/detailed';
				let _data = {
					id : this.getLoginInfo.id,
					token : this.getLoginInfo.token
				}
				fetch(url,_data,"POST").then(res=>{
					if(res.data.code){
						this.daysum = res.data.data.day_sum+''
						this.totalsum = res.data.data.sum+''
					}
				})
			},
			jumpDetail(item){
				let list = JSON.stringify(item)
				this.setPackages(list)
				uni.navigateTo({
					url:`/pages/fund/fund-live-detail`
				})
			},
			toDetail(item){
				let list = JSON.stringify(item)
				this.setPackages(list)
				uni.navigateTo({
					url:`/pages/fund/fund-regular-list`
				})
			},
			getSHopList(){
				let url = this.getRequestUrl + '/api/Shop/shop_list';
				let _data = {
					id : this.getLoginInfo.id,
					token : this.getLoginInfo.token,
					type: 1
				}
				fetch(url,_data,"POST").then(res=>{
					if(res.data.code){
						// this.liveCurlist = res.data.data;
						this.list = res.data.data;
						this.list.forEach((item,index)=>{
							this.list[index].percentage = (((parseInt((item.max/item.buy_num)*10000))/10000)*100).toFixed(2)
						})
					}
				})
			},
			jumpFundLiveList(){
				uni.navigateTo({
					url:'/pages/fund/fund-live-list'
				})
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			jumpList(){
				uni.navigateTo({
					url:'/pages/fund/list'
				})
			},
			empty(){
				this.showLoad = false;
				this.isClick = false;
			}
		}
	}
	
</script>

<style lang="scss" scoped>
	.index-top-nav-title{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30upx;
		.index-top-nav-l{
			display: flex;
			align-items: center;
			.index-top-nav-title-t{
				margin-left: 20upx;
				font-size:36upx;
				font-weight: bold;
			}
		}
		
	}
	.fund-live-title{
		background-color: #1D7DFF;
		color: #FFFFFF;
		padding: 10upx 0 74upx 0;
		position: relative;
		.fund-live-title-top{
			text-align: center;
			font-size: 24upx;
			display: flex;
			justify-content: center;
			align-items: center;
			view{
				display: flex;
				margin-left: 12upx;
				justify-content: space-between;
				align-items: center;
				border: 2upx solid #FFFFFF;
				padding: 8upx 30upx 8upx 8upx;
				font-size: 24upx;
				width: 120upx;
				text{
					font-size: 26upx;
					font-weight: 100;
					color: #FFFFFF;
				}
			}
		}
		.fund-live-title-center{
			font-size: 60upx;
			font-weight: bold;
			text-align: center;
			padding:46upx 0 56upx 0;
		}
		.fund-live-title-bottom{
			background-color: #FFFFFF;
			border-radius: 10upx;
			position: absolute;
			width: 690upx;
			left: 50%;
			transform: translate(-50%,50%);
			bottom: 0;
			display: flex;
			align-items: center;
			margin-bottom: -20upx;
			padding: 20upx 0;
			box-shadow: 2upx 2upx 10upx #e3e3e3;
			.fund-live-title-bottom-item{
				&:first-of-type{
					position: relative;
					&::after{
						position: absolute;
						right: 0;
						top: 0;
						height: 100%;
						width: 2upx;
						content:"";
						background-color: #a4a4a4;
					}
				}
				color: #282828;
				flex: 1;
				text-align: center;
				text{
					font-size: 24upx;
				}
				view{
					font-size: 44upx;
					font-weight: bold;
				}
			}
		}
	}
	.fund-regular-content{
		border-top: 120upx solid #f0f0f0;
		.fund-regular-content-title{
			line-height: 104upx;
			padding-left: 30upx;
			border-bottom: 1upx solid #d3d3d3;
		}
		.fund-ragular-content-item{
			border-bottom: 1upx solid #d3d3d3;
			.fund-ragular-content-item-title{
				display: flex;
				justify-content: space-between;
				padding: 24upx 30upx;
				align-items: center;
				.fund-ragular-content-item-title-i{
					display: flex;
					align-items: center;
					view{
						background-color: #166AFE;
						padding:6upx 10upx;
						color: #FFFFFF;
						font-size: 24upx;
						margin-right: 16upx;
					}
					text{
						font-size: 28upx;
						color: #000000;
					}
				}
				text{
					color: #000000;
					font-size: 20upx;
				}
			}
			.fund-ragular-content-item-content{
				display: flex;
				justify-content: space-between;
				padding: 10upx 30upx 28upx;
				align-items: center;
				.fund-ragular-content-item-title-l{
					view{
						font-size: 60upx;
						font-weight: bold;
						color: #000000;
					}
					text{
						font-size: 20upx;
					}
				}
				.fund-ragular-content-item-title-c{
					view{
						font-size: 24upx;
						// width: 350upx;
						padding: 0 15upx;
						height: 40upx;
						line-height: 40upx;
						text-align: center;
						font-weight: bold;
						background: linear-gradient(to right, #ffffff, #166afe);
					}
				}
				.fund-ragular-content-item-title-r{
					text-align: center;
					view{
						color: #166AFE;
						font-size: 30upx;
						font-weight: bold;
						margin-bottom: 46upx;
					}
					text{
						font-size: 24upx;
						color: #166AFE;
					}
				}
			}
		}
	}
</style>